D_LIBMSLOG_LIBS :=`pkg-config --libs libmslog`
D_LIBMSLOG_INCLUDES :=`pkg-config --cflags libmslog`
D_LIBMSCOMMON_LIBS :=`pkg-config --libs libmscommon`
D_LIBMSCOMMON_INCLUDES :=`pkg-config --cflags libmscommon`
D_LIBMSPROTOCOL_LIBS :=`pkg-config --libs libmsprotocol`
D_LIBMSPROTOCOL_INCLUDES :=`pkg-config --cflags libmsprotocol`
D_LIBMSTOOL_LIBS :=`pkg-config --libs libmstool`
D_LIBMSTOOL_INCLUDES :=`pkg-config --cflags libmstool`
C_INCLUDE=${D_BASEAPI_FLAGS} -Isrc -Isrc/audio_input -Isrc/audio_output ${D_LIBMSLOG_INCLUDES} ${D_LIBMSCOMMON_INCLUDES} ${D_LIBMSPROTOCOL_INCLUDES}
C_LIBS=${D_LIBMSLOG_LIBS} ${D_LIBMSCOMMON_LIBS} ${D_LIBMSPROTOCOL_LIBS} 

libmstool_CC=${CC}
libmstool_SRC=${C_SRC}
libmstool_CFLAGS=${C_INCLUDE} ${C_LIBS} ${CFLAGS_SHARE} 

ms_automount_CC=${CC}
ms_automount_SRC=msautomount_sample.c
ms_automount_CFLAGS=${C_INCLUDE} ${C_LIBS}  ${D_LIBMSTOOL_INCLUDES} ${D_LIBMSTOOL_LIBS}

DBG_FLAG=-g -rdynamic

x8664:    libmstool     install ms_automount
x8664_gdb:libmstool_gdb install ms_automount

libmstool: 
	mkdir -p $(OUT_LIB)
	mkdir -p $(OUT_INCLUDE)
	cp -fr src/*.h $(OUT_INCLUDE)
	$($@_CC)  $($@_SRC)  $($@_CFLAGS)  -o $(OUT_LIB)/$(PROGRAM_NAME).so 
libmstool_gdb: 
	mkdir -p $(OUT_LIB)
	mkdir -p $(OUT_INCLUDE)
	cp -fr src/*.h $(OUT_INCLUDE)
	$(libmstool_CC)  $(libmstool_SRC)  $(libmstool_CFLAGS) ${DBG_FLAG} -o $(OUT_LIB)/$(PROGRAM_NAME).so  
	
ms_automount: 
	mkdir -p $(OUT_BIN)
	$($@_CC)  $($@_SRC)  $($@_CFLAGS) ${DBG_FLAG} -o $(OUT_BIN)/$@ 
	cp -fr $(OUT_BIN)/$@ 	${prefix_x8664}/bin/

install:
	mkdir -p  ${prefix_x8664}/lib/ 
	mkdir -p  ${prefix_x8664}/include/   
	mkdir -p  ${prefix_x8664}/lib/pkgconfig/ 
	cp -fr $(OUT_LIB)/$(PROGRAM_NAME).so	${prefix_x8664}/lib/     
	cp -fr $(OUT_INCLUDE)			${prefix_x8664}/include/	     
	cp -fr platform/$(PROGRAM_NAME).pc		${prefix_x8664}/lib/pkgconfig/
uninstall:
	rm -fr ${prefix_x8664}/lib/$(PROGRAM_NAME).so 
	rm -fr ${prefix_x8664}/include/$(PROGRAM_NAME)
	rm -fr ${prefix_x8664}/lib/pkgconfig/$(PROGRAM_NAME).pc
